package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;
import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.ReceiveLaudEntity;
import com.sgb.knowledgeshare.view.activity.ShareMagessLandActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MToast;
import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by fq on 2020/9/24 0024
 * Description：
 */
public class ShareMagessLandModel extends ViewModel {

    ShareMagessLandActivity sharemagesslandactivity;

    public void setActivity(ShareMagessLandActivity shareMagessLandActivity) {
        sharemagesslandactivity = shareMagessLandActivity;
    }

//  消息模块我收到的赞
    public void getReceivelLaud(int page) {
        Map map = new HashMap();
        map.put("pageNum",page);
        map.put("pageSize",20);
        DialogHelper.showProgressDialog(sharemagesslandactivity, null, "加载中...", 0, true, null).setCanceledOnTouchOutside(false);
        ShareConfig.getInstance().getApi().getReceiveLaud(map).enqueue(new ICallBack<BaseEntity<ReceiveLaudEntity>>() {
            @Override
            public void onSuccess(BaseEntity<ReceiveLaudEntity> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    sharemagesslandactivity.setReceivelLaud(data.getData());
                }
            }
        });
    }

}
